package com.aplink.generic.pojo.googlemaps;

import java.lang.reflect.Type;

import com.aplink.generic.constant.type.DirectionsStatus;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

public class DirectionsResult implements JsonDeserializer<DirectionsResult> {
	private DirectionsRoutes mDirectionsRoutes;
	private DirectionsStatus mDirectionsStatus;

	@Override
	public DirectionsResult deserialize(JsonElement jsonElement, Type type,
	        JsonDeserializationContext context) throws JsonParseException {
		DirectionsResult directionsResult = new DirectionsResult();
		JsonObject jsonObject = jsonElement.getAsJsonObject();
		directionsResult.mDirectionsStatus = DirectionsStatus.get(jsonObject
		        .get("status").getAsString());
		directionsResult.mDirectionsRoutes = context.deserialize(jsonObject
		        .get("routes").getAsJsonArray().get(0), DirectionsRoutes.class);
		return directionsResult;
	}

	public DirectionsRoutes getDirectionsRoutes() {
		return mDirectionsRoutes;
	}

	public DirectionsStatus getDirectionsStatus() {
		return mDirectionsStatus;
	}

	public void setDirectionsRoutes(DirectionsRoutes directionsRoutes) {
		mDirectionsRoutes = directionsRoutes;
	}

	public void setDirectionsStatus(DirectionsStatus directionsStatus) {
		mDirectionsStatus = directionsStatus;
	}

}
